package com.tripcube.system.api;

import com.tripcube.common.core.web.page.TableDataInfo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import com.tripcube.common.core.constant.ServiceNameConstants;
import com.tripcube.common.core.domain.R;
import com.tripcube.system.api.domain.SysFile;
import com.tripcube.system.api.factory.RemoteFileFallbackFactory;

import java.util.List;

/**
 * 文件服务
 * 
 * @author alander110
 */
@FeignClient(contextId = "remoteFileService", value = ServiceNameConstants.FILE_SERVICE, fallbackFactory = RemoteFileFallbackFactory.class)
public interface RemoteFileService
{
    /**
     * 上传文件
     *
     * @param file 文件信息
     * @return 结果
     */
    @PostMapping(value = "/file/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public R<SysFile> upload(@RequestPart(value = "file") MultipartFile file);

    /**
     * 批量上传文件
     */
    @PostMapping(value = "/file/uploads", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public R<List<SysFile>> uploads(@RequestPart("files") MultipartFile[] files);

    /**
     * 文件删除请求
     *
     * @param fileId 文件id
     */
    @DeleteMapping("/file/delete/{fileId}")
    public R<Boolean> delete(@PathVariable Long fileId);


    /**
     * 批量删除文件
     */
    @DeleteMapping("/file/delete")
    public R<Boolean> delete(@RequestBody Long[] fileIds);

    /**
     * 根据文件ID获取文件信息
     */
    @GetMapping("/file/info/{fileId}")
    public R<SysFile> getInfo(@PathVariable Long fileId);


    /**
     * 获取文件列表
     */
    @GetMapping("/file/list")
    public R<TableDataInfo> list(SysFile sysFile);
}
